package com.dao;

import com.pojo.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserDao {
    @Select("select * from mall_user where username = #{username}")
    User findByUsername(String username);

    @Update("insert into mall_user values (null,#{username},#{password},#{email},#{image},0,#{code})")
    int add(User user);

    @Select("select * from mall_user where code = #{code};")
    User findByCode(String code);

    @Update("update mall_user set status = 1 where id = #{id};")
    int updateById(int id);

    @Select("select * from mall_user where username = #{username} and password = #{password}")
    User findByUsernameAndPassword(@Param("username") String username, @Param("password") String password);

    @Update("update mall_user set password = #{password} where id = #{id}")
    int updatePwd(@Param("password") String password, @Param("id") int id);

    @Select("select * from mall_user;")
    List<User> findAll();
}
